// This do-file builds our dataset of outcomes

// Dummy equal to one if an election took place that year
use "$project_path/data/3_cleaned/presidential_elections", clear
append using "$project_path/data/3_cleaned/parliamentary_elections"
keep Country Year
duplicates drop
gen election = 1
lab var election "Election took place"
tempfile elections
save `elections'

// Country performance outcomes
use "$project_path/data/2_intermediary/outcomes/outcomes_pwt.dta", clear
merge 1:1 Country Year using "$project_path/data/2_intermediary/outcomes/outcomes_imf.dta", nogen
merge 1:1 Country Year using "$project_path/data/2_intermediary/outcomes/outcomes_ilo.dta", nogen
merge 1:1 Country Year using "$project_path/data/2_intermediary/outcomes/outcomes_wb.dta", nogen
merge 1:1 Country Year using "$project_path/data/2_intermediary/outcomes/outcomes_undp.dta", nogen
merge 1:1 Country Year using "$project_path/data/2_intermediary/outcomes/outcomes_vdem.dta", nogen
merge 1:1 Country Year using "$project_path/data/1_input/outcomes/other/additional_outcomes.dta", nogen
merge 1:1 Country Year using `elections', assert(master match) nogen
replace election = 0 if election==.

sort Country Year
format Country %25s
notes drop _dta

compress
label data "Outcomes database -- Marx, Pons, and Rollet (2024)"
save "$project_path/data/3_cleaned/outcomes", replace
